package com.example.controller.user;

import com.example.common.Result;
import com.example.service.ArticleService;
import com.example.vo.CategoryDistributionVO;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户文章分类分布控制器
 */
@Slf4j
@RestController
@RequestMapping("/api/user/article")
public class CategoryDistributionController {
    
    @Resource
    private ArticleService articleService;
    
    @Operation(summary = "获取用户文章分类分布", description = "用于仪表盘文章分类分布图表")
    @PostMapping("/category/distribution")
    public Result<List<CategoryDistributionVO>> getCategoryDistribution() {
        log.info("API前缀版本 - 获取用户文章分类分布 API 被调用");
        List<CategoryDistributionVO> distribution = articleService.getCategoryDistribution();
        log.info("API前缀版本 - 返回分类分布数据: {}", distribution);
        return Result.success(distribution);
    }
} 